package cn.yuanqiao.web.controller.cqbc;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.cqbc.inspectionLog.domain.LogDetails;
import cn.yuanqiao.cqbc.inspectionLog.service.ILogDetailsService;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.core.page.TableDataInfo;

/**
 * 日志详情Controller
 * 
 * @author xy
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/cqbc/logDetails")
public class LogDetailsController extends BaseController
{
    @Autowired
    private ILogDetailsService logDetailsService;

    /**
     * 查询日志详情列表
     */
   // @RequiresPermissions("cqbc:logDetails:list")
    @GetMapping("/list")
    public TableDataInfo list(LogDetails logDetails)
    {
        startPage();
        List<LogDetails> list = logDetailsService.selectLogDetailsList(logDetails);
        return getDataTable(list);
    }

    /**
     * 导出日志详情列表
     */
  //  @RequiresPermissions("cqbc:logDetails:export")
    @Log(title = "日志详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LogDetails logDetails)
    {
        List<LogDetails> list = logDetailsService.selectLogDetailsList(logDetails);
        ExcelUtil<LogDetails> util = new ExcelUtil<LogDetails>(LogDetails.class);
        util.exportExcel(response, list, "日志详情数据");
    }

    /**
     * 获取日志详情详细信息
     */
    //@RequiresPermissions("cqbc:logDetails:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(logDetailsService.selectLogDetailsById(id));
    }

    /**
     * 新增日志详情
     */
 //   @RequiresPermissions("cqbc:logDetails:add")
    @Log(title = "日志详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LogDetails logDetails)
    {
        return toAjax(logDetailsService.insertLogDetails(logDetails));
    }

    /**
     * 修改日志详情
     */
   // @RequiresPermissions("cqbc:logDetails:edit")
    @Log(title = "日志详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LogDetails logDetails)
    {
        return toAjax(logDetailsService.updateLogDetails(logDetails));
    }

    /**
     * 删除日志详情
     */
   // @RequiresPermissions("cqbc:logDetails:remove")
    @Log(title = "日志详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(logDetailsService.deleteLogDetailsByIds(ids));
    }
}
